var that, _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

function address(e) {
    var t = {
        action: "getAddress",
        contr: "my",
        token: wx.getStorageSync("token")
    };
    _tools2.default.request(t, function(t) {
        t.info.address ? e.setData({
            consignee: t.info.address.name,
            tel: t.info.address.phone,
            detailAddress: t.info.address.address
        }) : wx.chooseAddress({
            success: function(t) {
                e.setData({
                    consignee: t.userName,
                    tel: t.telNumber,
                    detailAddress: t.provinceName + t.cityName + t.countyName + t.detailInfo
                });
            }
        });
    });
}

Page({
    data: {
        consignee: "",
        tel: "",
        detailAddress: "",
        card: "",
        nav: {
            title: "收货地址",
            showHome: !0,
            isHomePage: !0
        },
        loading: !1
    },
    onLoad: function(t) {
        that = this, t.id && (that.data.id = t.id), address(that);
    },
    onReady: function() {
        wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#000000"
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    nameInput: function(t) {
        this.setData({
            consignee: t.detail.value
        });
    },
    telInput: function(t) {
        this.setData({
            tel: t.detail.value
        });
    },
    cardInput: function(t) {
        this.setData({
            card: t.detail.value
        });
    },
    detailInput: function(t) {
        this.setData({
            detailAddress: t.detail.value
        });
    },
    layerclose: function(t) {
        this.setData({
            layer: !1
        });
    },
    submit: function(t) {
        this.setData({
            layer: !0
        });
    },
    btnsubmit: function(t) {
        var e = this;
        e.setData({
            layer: !1
        });
        var a = {
            action: "setAddress",
            contr: "my"
        }, o = wx.getStorageSync("token"), n = e.data.consignee, s = e.data.tel, i = (e.data.card, 
        e.data.detailAddress);
        "" != n ? "" != s ? "" != i ? (a.token = o, a.formid = t.detail.formId, a.name = n, 
        a.phone = s, a.address = i, _tools2.default.request(a, function(t) {
            wx.navigateBack();
        })) : _tools2.default.showNotice("请填写详细地址") : _tools2.default.showNotice("请填写电话") : _tools2.default.showNotice("请填写收货人");
    },
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_bargain/pages/index/index?parent_id=" + this.data.share.member_id
        };
    }
});